//
//  MainTabBarController.m
//  TravelTV
//
//  Created by JuZhenBaoiMac on 2017/3/20.
//  Copyright © 2017年 JuZhenBaoiMac. All rights reserved.
//

#import "MainTabBarController.h"
#import "BaseNavigationC.h"
//社交
#import "MessageViewController.h"
#import "JWMeViewController.h"
#import "JWFindViewController.h"
#import "JWAddressBookViewController.h"
#import "JWDialPadViewController.h"

@interface MainTabBarController ()

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.translucent = NO;
    
    
//    //添加子控制器
        
        MessageViewController *Message_VC = [[MessageViewController alloc]init];
        JWAddressBookViewController *JWAddressBook_VC = [[JWAddressBookViewController alloc]init];
        JWDialPadViewController *JWDialPad_VC = [[JWDialPadViewController alloc]init];
        JWFindViewController *JWFind_VC = [[JWFindViewController alloc]init];
        JWMeViewController *JWMe_VC = [[JWMeViewController alloc]init];
        
        Message_VC.isFirstClass = YES;
        JWAddressBook_VC.isFirstClass = YES;
        JWDialPad_VC.isFirstClass = YES;
        JWFind_VC.isFirstClass = YES;
        JWMe_VC.isFirstClass = YES;
        
        [self addChildVC:Message_VC title:@"消息" image:@"jw_tabbar_message" selectedImage:@"jw_tabbar_message_sel"];
        [self addChildVC:JWAddressBook_VC title:@"通讯录" image:@"jw_tabbar_addBook" selectedImage:@"jw_tabbar_addBook_sel"];
        [self addChildVC:JWDialPad_VC title:@"拨号盘" image:@"jw_tabbar_phone" selectedImage:@"jw_tabbar_phone_sel"];
        [self addChildVC:JWFind_VC title:@"发现" image:@"jw_tabbar_find" selectedImage:@"jw_tabbar_find_sel"];
        [self addChildVC:JWMe_VC title:@"今望" image:@"jw_tabbar_me" selectedImage:@"jw_tabbar_me_sel"];
   
}

/**
 *  添加一个子控制器
 *  @param childVC       子控制器
 *  @param title         标题
 *  @param image         图片
 *  @param selectedImage 选中的图片
 */
- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
    // 设置子控制器的文字(可以设置tabBar和navigationBar的文字)
    childVC.title = title;
    
    // 设置子控制器的tabBarItem图片
    childVC.tabBarItem.image = [[UIImage imageNamed:image]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 禁用图片渲染
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 设置文字的样式
    [childVC.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : kRGBColor(36, 36, 36)} forState:UIControlStateNormal];
    [childVC.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : UIColorHex(0xEEA72B)} forState:UIControlStateSelected];

    // 为子控制器包装导航控制器
    BaseNavigationC *navi = [[BaseNavigationC alloc] initWithRootViewController:childVC];
    navi.navigationBar.barTintColor = UIColorHex(0xEEA72B);// 设置导航栏背景颜色  #EEA72B
//    navi.navigationBar.barTintColor = [UIColor blackColor];// 设置导航栏背景颜色

    [navi.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:18],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];// 设置导航栏文字字体大小 文字的颜色
    // 添加子控制器
    [self addChildViewController:navi];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
